package com.ruoyi.web.bank.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.bank.domain.AaBank;
import com.ruoyi.web.bank.service.IAaBankService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 银行档案Controller
 * 
 * @author czr
 * @date 2024-09-29
 */
@RestController
@RequestMapping("/bank/bank")
public class AaBankController extends BaseController
{
    @Autowired
    private IAaBankService aaBankService;

    /**
     * 查询银行档案列表
     */
    @PreAuthorize("@ss.hasPermi('bank:bank:list')")
    @GetMapping("/list")
    public TableDataInfo list(AaBank aaBank)
    {
        startPage();
        List<AaBank> list = aaBankService.selectAaBankList(aaBank);
        return getDataTable(list);
    }

    /**
     * 导出银行档案列表
     */
    @PreAuthorize("@ss.hasPermi('bank:bank:export')")
    @Log(title = "银行档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AaBank aaBank)
    {
        List<AaBank> list = aaBankService.selectAaBankList(aaBank);
        ExcelUtil<AaBank> util = new ExcelUtil<AaBank>(AaBank.class);
        util.exportExcel(response, list, "银行档案数据");
    }

    /**
     * 获取银行档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('bank:bank:query')")
    @GetMapping(value = "/{cBankCode}")
    public AjaxResult getInfo(@PathVariable("cBankCode") String cBankCode)
    {
        return success(aaBankService.selectAaBankByCBankCode(cBankCode));
    }

    /**
     * 新增银行档案
     */
    @PreAuthorize("@ss.hasPermi('bank:bank:add')")
    @Log(title = "银行档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AaBank aaBank)
    {
        return toAjax(aaBankService.insertAaBank(aaBank));
    }

    /**
     * 修改银行档案
     */
    @PreAuthorize("@ss.hasPermi('bank:bank:edit')")
    @Log(title = "银行档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AaBank aaBank)
    {
        return toAjax(aaBankService.updateAaBank(aaBank));
    }

    /**
     * 删除银行档案
     */
    @PreAuthorize("@ss.hasPermi('bank:bank:remove')")
    @Log(title = "银行档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cBankCodes}")
    public AjaxResult remove(@PathVariable String[] cBankCodes)
    {
        return toAjax(aaBankService.deleteAaBankByCBankCodes(cBankCodes));
    }
}
